<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return '404';
});

Route::get('users/{channel}/openid', [\App\Http\Controllers\UsersController::class, 'openid'])->name('users.openid');
// 支付异步通知
Route::any('/pay/{gateway}/notify/{channel}', [\App\Http\Controllers\PayController::class, 'notify'])->name('pay.notify');
// 支付同步返回
Route::any('/pay/{gateway}/return/{order:trade_no}', [\App\Http\Controllers\PayController::class, 'return'])->name('pay.return');
// 获取订单状态
Route::any('/pay/{order:trade_no}/status', [\App\Http\Controllers\PayController::class, 'status'])->name('pay.status');
// 错误消息页面
Route::get('/error/message', [\App\Http\Controllers\Error\MessageController::class, 'index'])->name('error.message');
// 易支付兼容提交
Route::any('/epay/submit', [\App\Http\Controllers\Epay\OrdersController::class, 'submit'])->name('epay.submit');
// 订单支付
Route::get('/pay/{order:trade_no}', [\App\Http\Controllers\PayController::class, 'pay'])->name('pay');
// 支付测试
Route::get('/test', [\App\Http\Controllers\DemoController::class, 'index'])->name('pay.test');
Route::post('/test', [\App\Http\Controllers\DemoController::class, 'store']);
////
//Route::get('/test', function () {
//    parse_str('gmt_create=2021-04-10+18%3A31%3A48&charset=UTF-8&gmt_payment=2021-04-10+18%3A31%3A51&notify_time=2021-04-10+18%3A31%3A51&subject=%E8%AE%A2%E5%8D%95%E6%94%AF%E4%BB%98+-+202104101831424724407538&sign=WKmbdcdiXBOJm8PoyyL0qcIGzBGkjymCuBttS%2F7uRCFU0VS8Gm%2B4p%2FlEKDyJX83aFLMfNSOWLU9cG5FqZERb%2Bm2tWIhN8NR7bEXK%2FXEqXTCRuBKNSN6S6CWZP07byEby%2BuoFh7vyXXkuOqErUcXl7geFTrSPdJ3nwctPSqx1I4yVSGmXu09h6zju8z6F4zcznClilbsdRWicfcWpIADtZKnRl%2Bezg0g%2B%2BKPS7yd3mA9a1HYihPkkcC%2Bs4vCtZq3Ww5sxdPqEbW5yBeZJilhZx55vD6DTdvDgBgb%2BfltTCNaizNzJaCfrErq4ertVK0X0Y4LnMtopG%2B6AFpMyPMkh0Q%3D%3D&buyer_id=2088222395345542&invoice_amount=0.01&version=1.0&notify_id=2021041000222183151045541448554346&fund_bill_list=%5B%7B%22amount%22%3A%220.01%22%2C%22fundChannel%22%3A%22ALIPAYACCOUNT%22%7D%5D&notify_type=trade_status_sync&out_trade_no=202104101831442721316641&total_amount=0.01&trade_status=TRADE_SUCCESS&trade_no=2021041022001445541420338798&auth_app_id=2021001157625067&receipt_amount=0.01&point_amount=0.00&buyer_pay_amount=0.01&app_id=2021001157625067&sign_type=RSA2&seller_id=2088831222412351', $content);
//    dd($content);
//});



// 用户端路由
Route::get('v')->name('verification.verify');
Route::get('/user/login', [\App\Http\Controllers\User\Auth\LoginController::class, 'showLoginForm'])->name('user.login');
Route::post('/user/login', [\App\Http\Controllers\User\Auth\LoginController::class, 'login']);
Route::get('/user/register', [\App\Http\Controllers\User\Auth\RegisterController::class, 'showRegisterForm'])->name('user.register');
Route::post('/user/register', [\App\Http\Controllers\User\Auth\RegisterController::class, 'register']);
Route::delete('/user/logout', [\App\Http\Controllers\User\Auth\LogoutController::class, 'logout'])->name('user.logout');
Route::get('/user/setting', [\App\Http\Controllers\User\Auth\SettingController::class, 'showSettingForm'])->name('user.setting');
Route::put('/user/setting', [\App\Http\Controllers\User\Auth\SettingController::class, 'setting']);

Route::group([
    'prefix' => 'user',
    'as' => 'user.'
], function () {
    Route::redirect('/', '/user/dashboard');
    Route::get('/dashboard', [\App\Http\Controllers\User\DashboardController::class, 'index'])->name('dashboard');
    // 商户
    Route::get('/merchants', [\App\Http\Controllers\User\MerchantsController::class, 'index'])->name('merchants.index');
    Route::get('/merchants/{merchant}/edit', [\App\Http\Controllers\User\MerchantsController::class, 'edit'])->name('merchants.edit');
    Route::put('/merchants/{merchant}', [\App\Http\Controllers\User\MerchantsController::class, 'update'])->name('merchants.update');
    Route::get('/merchants/{merchant}/cash', [\App\Http\Controllers\User\MerchantsController::class, 'cash'])->name('merchants.cash');
    Route::post('/merchants/{merchant}/cash-draw', [\App\Http\Controllers\User\MerchantsController::class, 'cashDraw'])->name('merchants.cashdraw');

    // 订单
    Route::get('/orders', [\App\Http\Controllers\User\OrdersController::class, 'index'])->name('orders.index');
    Route::get('/orders/{order}/show', [\App\Http\Controllers\User\OrdersController::class, 'show'])->name('orders.show');
    Route::put('/orders/{order}/notify', [\App\Http\Controllers\User\OrdersController::class, 'notify'])->name('orders.notify');

    // 资金明细
    Route::get('/balance-logs', [\App\Http\Controllers\User\BalanceLogsController::class, 'index'])->name('balancelogs.index');

    // 提现记录
    Route::get('/cash-draws', [\App\Http\Controllers\User\CashDrawsController::class, 'index'])->name('cashdraws.index');

    // 提现信息
    Route::get('/cash-infos', [\App\Http\Controllers\User\CashInfosController::class, 'index'])->name('cashinfos.index');
    Route::put('/cash-infos/update', [\App\Http\Controllers\User\CashInfosController::class, 'update'])->name('cashinfos.update');
});
